{extend name="layout:base" /}{block name="content"}
<?php
$global=isSupperManagerForSession();
?>
<style>
    .table th {
        text-align: center;
    }

    .tip {
        position: absolute;
        background: #9FC;
        border-color: #F60;
        z-index: 9999;
        filter: alpha(opacity=80);
        -moz-opacity: 0.8;
        -khtml-opacity: 0.8;
        opacity: 0.8;
    }

    .hidden-detail {
        display: none;
    }

    .mypointer {
        width: 95%;
        overflow: hidden;
        height: 25px;
        line-height: 25px;
        cursor: pointer;
    }
</style>

<link rel="stylesheet" type="text/css" href="/static/admin/css/style.css"/>
<script src="/static/mimi/js/confirm/js/jquery-1.9.1.js"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>

<link rel="stylesheet" href="/static/mimi/css/animate.min.css" type="text/css"/>
<link rel="stylesheet" href="/static/mimi/css/font-awesome.min.css" type="text/css"/>

<section class="topBanners">
    <div class="icon"></div>
    <div class="topBannersNav">
        <span data-url="/admin/user/lists" onclick="ContentLoadGo('/admin/user/lists')">用户管理</span>
        >
        <span data-url="/admin/user/userAddGroup"
              onclick="ContentLoadGo('/admin/user/userAddGroup?uid=<?php echo $uid; ?>')">角色配置</span>
    </div>
</section>

<input type="hidden" value="" class="group_btn research" id="resource" page="1"/>
<section style="margin-top:10px;margin-left:20px;margin-right:auto;">

    <select id="gid" class="select" name="gid">
        <option value="">--选择角色--</option>
        <?php
        foreach($groupList as $k=>$v)
        {
        ?>
        <option value="<?php echo $v['id']; ?>"><?php echo $v['gname']; ?></option>
        <?php
        }
        ?>
    </select>
    <input type="button" value="添加" class="group_btn add"/>
    <br style="clear:both;width:0px;height:0px;">
</section>

<table class="table" style="margin-top:10px;width:700px;">
    <tr>
        <th style="width:100px;">ID</th>
        <th style="width:200px;">角色组</th>
        <th style="width:200px;">操作时间</th>
        <th style="width:200px;">操作</th>
    </tr>
    <?php
foreach($lists['data'] as $key=>$val)
    {
    ?>
    <tr data-id="<?php echo $val['id']; ?>">
        <td style="text-align:left;"><?php echo $val['id']; ?></td>

        <td><?php echo $val['gname'];?></td>
        <td><?php echo $val['op_ctime'];?></td>
        <td>
            <?php
	   if( ( in_array(21300,$ruleLists) || $global==1) )
		{
    	?>
            <input type="button" power="14003" value="删除" class="link_btn del"/>
            <?php
		}
		?>
        </td>
    </tr>

    <?php
}
?>
</table>
{include file="../application/admin/view/layout/page_tpl_new.html" /}
<script type="text/javascript">
    function myResearch() {
        var url = "/admin/user/userAddGroup";
        var generaData = $("#serach_section [name^='ser_']");
        var page = $("#cpage").val();
        var uid = "<?php  echo $uid; ?>";
        var param = {
            page: page,
            uid: uid
        };
        getSearchFormData(generaData, param);
        ContentLoadGo(url, param);
    }

    $(function () {
        //设置搜索栏
        $(".research").unbind().bind("click", function () {
            var page = $(this).attr("page");
            $("#cpage").val(page);
            myResearch();
        });


        $(".add").unbind().bind("click", function () {
            var that = this;
            var url = "/admin/user/userAddGroup";
            var uid = "<?php echo $uid; ?>";
            var gid = $("#gid").val();
            if (gid == "") {
                ErrTiShi("请选择角色");
                return;
            }
            var param = {
                uid: uid,
                gid: gid,
                sys_opt: 'addData'//后台判断编辑操作
            };
            AjaxRequest(url, param, function (data) {
                if (data.err == 0) {
                    SuccessTiShi("操作成功");
                    ContentLoadGo("/admin/user/userAddGroup?uid=" + uid);
                } else {
                    ErrTiShi(data.msg);
                }
            });
        });


//导航
        $(".topBannerItem").unbind().bind("click", function () {
            var attArr = $(this).attr();
            goToSelfLink(attArr);

        });


        $(".del").unbind().bind("click", function () {
            var that = this;
            var url = "/admin/user/delUserGroupData";
            var id = $(that).parent().parent().attr('data-id');
            var uid = "<?php echo $uid; ?>";
            var param = {
                id: id,
                uid: uid
            };
            cofirmsss_tishi(1, '您确定要删除吗?', function (id) {

                AjaxRequest(url, param, function (data) {
                    if (data.err == 0) {
                        SuccessTiShi("操作成功");

                        $(that).parent().parent().remove();
                        myResearch();
                    } else {
                        ErrTiShi("操作失败");
                    }
                });

            });
        });

//全选
        $("#all").unbind().bind("click", function () {
            if (this.checked) {
                $(".checkBoxInput").attr("checked", true);
                $(".checkBoxInput").prop("checked", true);
            } else {
                $(".checkBoxInput").attr("checked", false);
                $(".checkBoxInput").prop("checked", false);
            }
            var se = getAllSelectItem();
        });

    });
</script>
<script>
    $(function () {
        $("[data-toggle='tooltip']").tooltip();
    });
</script>
{/block}
   